package com.codebattery.controller;


import com.codebattery.domain.model.AccountInfo;
import com.codebattery.service.AccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api("账户接口")
@RestController
@RequestMapping(value="account")
public class AccountController {

    private static final Logger logger = LoggerFactory.getLogger(AccountController.class);

    @Autowired
    private AccountService accountService;

    @ApiOperation(value="获取所有账户信息",notes="")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query",  name = "page", value = "当前页", required = true),
            @ApiImplicitParam(paramType = "query",  name = "pageSize", value = "分页大小", required = true)})
    @RequestMapping(value="",method = RequestMethod.POST)
    @ResponseBody
    public Page<AccountInfo> listAll(@PageableDefault(page = 0, size = 20) Pageable pageable) {
        logger.debug("获取所有账户信息");

        Page<AccountInfo> infos = accountService.listAll(pageable);

        return infos;
    }

}
